home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_guile.idb / usr / freeware / include / libguile / validate.h.z / validate.h
Encoding:
C/C++ Source or Header  |  2002-07-08  |  16.8 KB  |  544 lines

  1. /* Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
  2.  *
  3.  * This program is free software; you can redistribute it and/or modify
  4.  * it under the terms of the GNU General Public License as published by
  5.  * the Free Software Foundation; either version 2, or (at your option)
  6.  * any later version.
  7.  *
  8.  * This program is distributed in the hope that it will be useful,
  9.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.  * GNU General Public License for more details.
  12.  *
  13.  * You should have received a copy of the GNU General Public License
  14.  * along with this software; see the file COPYING.  If not, write to
  15.  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  16.  * Boston, MA 02111-1307 USA
  17.  *
  18.  * As a special exception, the Free Software Foundation gives permission
  19.  * for additional uses of the text contained in its release of GUILE.
  20.  *
  21.  * The exception is that, if you link the GUILE library with other files
  22.  * to produce an executable, this does not by itself cause the
  23.  * resulting executable to be covered by the GNU General Public License.
  24.  * Your use of that executable is in no way restricted on account of
  25.  * linking the GUILE library code into it.
  26.  *
  27.  * This exception does not however invalidate any other reasons why
  28.  * the executable file might be covered by the GNU General Public License.
  29.  *
  30.  * This exception applies only to the code released by the
  31.  * Free Software Foundation under the name GUILE.  If you copy
  32.  * code from other Free Software Foundation releases into a copy of
  33.  * GUILE, as the General Public License permits, the exception does
  34.  * not apply to the code that you add in this way.  To avoid misleading
  35.  * anyone as to the status of such modified files, you must delete
  36.  * this exception notice from them.
  37.  *
  38.  * If you write modifications of your own for GUILE, it is your choice
  39.  * whether to permit this exception to apply to your modifications.
  40.  * If you do not wish that, delete this exception notice.  */
  41.  
  42. /* Written by Greg J. Badros <gjb@cs.washington.edu>, Dec-1999 */
  43.  
  44. #ifndef SCM_VALIDATE_H__
  45. #define SCM_VALIDATE_H__
  46.  
  47. #define SCM_SYSERROR do { scm_syserror (FUNC_NAME); } while (0)
  48.  
  49. #define SCM_MEMORY_ERROR do { scm_memory_error (FUNC_NAME); } while (0)
  50.  
  51. #define SCM_SYSERROR_MSG(str, args, val) \
  52.   do { scm_syserror_msg (FUNC_NAME, (str), (args), (val)); } while (0)
  53.  
  54. #define SCM_MISC_ERROR(str, args) \
  55.   do { scm_misc_error (FUNC_NAME, str, args); } while (0)
  56.  
  57. #define SCM_WRONG_NUM_ARGS() \
  58.   do { scm_error_num_args_subr (FUNC_NAME); } while (0)
  59.  
  60. #define SCM_WRONG_TYPE_ARG(pos, obj) \
  61.   do { scm_wrong_type_arg (FUNC_NAME, pos, obj); } while (0)
  62.  
  63. #define SCM_NUM2SIZE(pos, arg) (scm_num2size (arg, pos, FUNC_NAME))
  64.  
  65. #define SCM_NUM2SIZE_DEF(pos, arg, def) \
  66.   (SCM_UNBNDP (arg) ? def : scm_num2size (arg, pos, FUNC_NAME))
  67.  
  68. #define SCM_NUM2PTRDIFF(pos, arg) (scm_num2ptrdiff (arg, pos, FUNC_NAME))
  69.  
  70. #define SCM_NUM2PTRDIFF_DEF(pos, arg, def) \
  71.   (SCM_UNBNDP (arg) ? def : scm_num2ptrdiff (arg, pos, FUNC_NAME))
  72.  
  73. #define SCM_NUM2SHORT(pos, arg) (scm_num2short (arg, pos, FUNC_NAME))
  74.  
  75. #define SCM_NUM2SHORT_DEF(pos, arg, def) \
  76.   (SCM_UNBNDP (arg) ? def : scm_num2short (arg, pos, FUNC_NAME))
  77.  
  78. #define SCM_NUM2USHORT(pos, arg) (scm_num2ushort (arg, pos, FUNC_NAME))
  79.  
  80. #define SCM_NUM2USHORT_DEF(pos, arg, def) \
  81.   (SCM_UNBNDP (arg) ? def : scm_num2ushort (arg, pos, FUNC_NAME))
  82.  
  83. #define SCM_NUM2INT(pos, arg) (scm_num2int (arg, pos, FUNC_NAME))
  84.  
  85. #define SCM_NUM2INT_DEF(pos, arg, def) \
  86.   (SCM_UNBNDP (arg) ? def : scm_num2int (arg, pos, FUNC_NAME))
  87.  
  88. #define SCM_NUM2UINT(pos, arg) (scm_num2uint (arg, pos, FUNC_NAME))
  89.  
  90. #define SCM_NUM2UINT_DEF(pos, arg, def) \
  91.   (SCM_UNBNDP (arg) ? def : scm_num2uint (arg, pos, FUNC_NAME))
  92.  
  93. #define SCM_NUM2ULONG(pos, arg) (scm_num2ulong (arg, pos, FUNC_NAME))
  94.  
  95. #define SCM_NUM2ULONG_DEF(pos, arg, def) \
  96.   (SCM_UNBNDP (arg) ? def : scm_num2ulong (arg, pos, FUNC_NAME))
  97.  
  98. #define SCM_NUM2LONG(pos, arg) (scm_num2long (arg, pos, FUNC_NAME))
  99.  
  100. #define SCM_NUM2LONG_DEF(pos, arg, def) \
  101.   (SCM_UNBNDP (arg) ? def : scm_num2long (arg, pos, FUNC_NAME))
  102.  
  103. #define SCM_NUM2LONG_LONG(pos, arg) \
  104.   (scm_num2long_long (arg, pos, FUNC_NAME))
  105.  
  106. #define SCM_NUM2LONG_LONG_DEF(pos, arg, def) \
  107.   (SCM_UNBNDP (arg) ? def : scm_num2long_long (arg, pos, FUNC_NAME))
  108.  
  109. #define SCM_NUM2ULONG_LONG(pos, arg) \
  110.   (scm_num2ulong_long (arg, pos, FUNC_NAME))
  111.  
  112. #define SCM_NUM2ULONG_LONG_DEF(pos, arg, def) \
  113.   (SCM_UNBNDP (arg) ? def : scm_num2ulong_long (arg, pos, FUNC_NAME))
  114.  
  115. #define SCM_NUM2FLOAT(pos, arg) \
  116.   (scm_num2float (arg, pos, FUNC_NAME))
  117.  
  118. #define SCM_NUM2DOUBLE(pos, arg) \
  119.   (scm_num2double (arg, pos, FUNC_NAME))
  120.  
  121. #define SCM_OUT_OF_RANGE(pos, arg) \
  122.   do { scm_out_of_range_pos (FUNC_NAME, arg, SCM_MAKINUM (pos)); } while (0)
  123.  
  124. #define SCM_ASSERT_RANGE(pos, arg, f) \
  125.   do { if (!(f)) scm_out_of_range_pos (FUNC_NAME, arg, SCM_MAKINUM (pos)); } while (0)
  126.  
  127. #define SCM_MUST_MALLOC_TYPE(type) \
  128.   ((type *) scm_must_malloc (sizeof (type), FUNC_NAME))
  129.  
  130. #define SCM_MUST_MALLOC_TYPE_NUM(type, num) \
  131.   ((type *) scm_must_malloc (sizeof (type) * (num), FUNC_NAME))
  132.  
  133. #define SCM_MUST_MALLOC(size) (scm_must_malloc ((size), FUNC_NAME))
  134.  
  135. #define SCM_MAKE_VALIDATE(pos, var, pred) \
  136.   do { \
  137.     SCM_ASSERT_TYPE (SCM_ ## pred (var), var, pos, FUNC_NAME, #pred); \
  138.   } while (0)
  139.  
  140.  
  141.  
  142. #define SCM_VALIDATE_REST_ARGUMENT(x) \
  143.   do { \
  144.     if (SCM_DEBUG_REST_ARGUMENT) { \
  145.       if (scm_ilength (x) < 0) { \
  146.         SCM_MISC_ERROR ("Rest arguments do not form a proper list.", SCM_EOL); \
  147.       } \
  148.     } \
  149.   } while (0)
  150.  
  151. #define SCM_VALIDATE_NIM(pos, scm) SCM_MAKE_VALIDATE (pos, scm, NIMP)
  152.  
  153. #define SCM_VALIDATE_BOOL(pos, flag) SCM_MAKE_VALIDATE(pos, flag, BOOLP)
  154.  
  155. #define SCM_VALIDATE_BOOL_COPY(pos, flag, cvar) \
  156.   do { \
  157.     SCM_ASSERT (SCM_BOOLP (flag), flag, pos, FUNC_NAME); \
  158.     cvar = SCM_EQ_P (flag, SCM_BOOL_T) ? 1 : 0; \
  159.   } while (0)
  160.  
  161. #define SCM_VALIDATE_CHAR(pos, scm) SCM_MAKE_VALIDATE (pos, scm, CHARP)
  162.  
  163. #define SCM_VALIDATE_CHAR_COPY(pos, scm, cvar) \
  164.   do { \
  165.     SCM_ASSERT (SCM_CHARP (scm), scm, pos, FUNC_NAME); \
  166.     cvar = SCM_CHAR (scm); \
  167.   } while (0)
  168.  
  169. #define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE (pos, str, STRINGP)
  170.  
  171. #define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \
  172.   do { \
  173.     SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \
  174.     cvar = SCM_STRING_CHARS(str); \
  175.   } while (0)
  176.  
  177. /* validate a string and optional start/end arguments which default to
  178.    0/string-len.  this is unrelated to the old shared substring
  179.    support, so please do not deprecate it :) */
  180. #define SCM_VALIDATE_SUBSTRING_SPEC_COPY(pos_str, str, c_str, \
  181.                                          pos_start, start, c_start,\
  182.                                          pos_end, end, c_end) \
  183.   do {\
  184.     SCM_VALIDATE_STRING_COPY (pos_str, str, c_str);\
  185.     SCM_VALIDATE_INUM_DEF_COPY (pos_start, start, 0, c_start);\
  186.     SCM_VALIDATE_INUM_DEF_COPY (pos_end, end, SCM_STRING_LENGTH (str), c_end);\
  187.     SCM_ASSERT_RANGE (pos_start, start,\
  188.                       0 <= c_start \
  189.                       && (size_t) c_start <= SCM_STRING_LENGTH (str));\
  190.     SCM_ASSERT_RANGE (pos_end, end,\
  191.               c_start <= c_end \
  192.                       && (size_t) c_end <= SCM_STRING_LENGTH (str));\
  193.   } while (0)
  194.  
  195. #define SCM_VALIDATE_REAL(pos, z) SCM_MAKE_VALIDATE (pos, z, REALP)
  196.  
  197. #define SCM_VALIDATE_NUMBER(pos, z) SCM_MAKE_VALIDATE (pos, z, NUMBERP)
  198.  
  199. #define SCM_VALIDATE_INUM(pos, k) SCM_MAKE_VALIDATE (pos, k, INUMP)
  200.  
  201. #define SCM_VALIDATE_INUM_COPY(pos, k, cvar) \
  202.   do { \
  203.     SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
  204.     cvar = SCM_INUM (k); \
  205.   } while (0)
  206.  
  207. #define SCM_VALIDATE_USHORT_COPY(pos, k, cvar) \
  208.   do { \
  209.     cvar = SCM_NUM2USHORT (pos, k); \
  210.   } while (0)
  211.  
  212. #define SCM_VALIDATE_SHORT_COPY(pos, k, cvar) \
  213.   do { \
  214.     cvar = SCM_NUM2SHORT (pos, k); \
  215.   } while (0)
  216.  
  217. #define SCM_VALIDATE_UINT_COPY(pos, k, cvar) \
  218.   do { \
  219.     cvar = SCM_NUM2UINT (pos, k); \
  220.   } while (0)
  221.  
  222. #define SCM_VALIDATE_INT_COPY(pos, k, cvar) \
  223.   do { \
  224.     cvar = SCM_NUM2INT (pos, k); \
  225.   } while (0)
  226.  
  227. #define SCM_VALIDATE_ULONG_COPY(pos, k, cvar) \
  228.   do { \
  229.     cvar = SCM_NUM2ULONG (pos, k); \
  230.   } while (0)
  231.  
  232. #define SCM_VALIDATE_LONG_COPY(pos, k, cvar) \
  233.   do { \
  234.     cvar = SCM_NUM2LONG (pos, k); \
  235.   } while (0)
  236.  
  237. #define SCM_VALIDATE_FLOAT_COPY(pos, k, cvar) \
  238.   do { \
  239.     cvar = SCM_NUM2FLOAT (pos, k); \
  240.   } while (0)
  241.  
  242. #define SCM_VALIDATE_DOUBLE_COPY(pos, k, cvar) \
  243.   do { \
  244.     cvar = SCM_NUM2DOUBLE (pos, k); \
  245.   } while (0)
  246.  
  247. #define SCM_VALIDATE_BIGINT(pos, k) SCM_MAKE_VALIDATE (pos, k, BIGP)
  248.  
  249. #define SCM_VALIDATE_INUM_MIN(pos, k, min) \
  250.   do { \
  251.     SCM_ASSERT (SCM_INUMP(k), k, pos, FUNC_NAME); \
  252.     SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
  253.   } while (0)
  254.  
  255. #define SCM_VALIDATE_INUM_MIN_COPY(pos, k, min, cvar) \
  256.   do { \
  257.     SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
  258.     SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
  259.     cvar = SCM_INUM (k); \
  260.   } while (0)
  261.  
  262. #define SCM_VALIDATE_INUM_MIN_DEF_COPY(pos, k, min, default, cvar) \
  263.   do { \
  264.     if (SCM_UNBNDP (k)) \
  265.       k = SCM_MAKINUM (default); \
  266.     SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
  267.     SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
  268.     cvar = SCM_INUM (k); \
  269.   } while (0)
  270.  
  271. #define SCM_VALIDATE_INUM_DEF(pos, k, default) \
  272.   do { \
  273.     if (SCM_UNBNDP (k)) \
  274.       k = SCM_MAKINUM (default); \
  275.     else SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
  276.   } while (0)
  277.  
  278. #define SCM_VALIDATE_INUM_DEF_COPY(pos, k, default, cvar) \
  279.   do { \
  280.     if (SCM_UNBNDP (k)) \
  281.       { \
  282.         k = SCM_MAKINUM (default); \
  283.         cvar = default; \
  284.       } \
  285.     else \
  286.       { \
  287.         SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
  288.         cvar = SCM_INUM (k); \
  289.       } \
  290.   } while (0)
  291.  
  292. #define SCM_VALIDATE_DOUBLE_DEF_COPY(pos, k, default, cvar) \
  293.   do { \
  294.     if (SCM_UNBNDP (k)) \
  295.       { \
  296.         k = scm_make_real (default); \
  297.         cvar = default; \
  298.       } \
  299.     else \
  300.       { \
  301.         cvar = SCM_NUM2DOUBLE (pos, k); \
  302.       } \
  303.   } while (0)
  304.  
  305. /* [low,high) */
  306. #define SCM_VALIDATE_INUM_RANGE(pos,k,low,high) \
  307.   do { SCM_ASSERT(SCM_INUMP(k), k, pos, FUNC_NAME); \
  308.        SCM_ASSERT_RANGE(pos,k, \
  309.                         (SCM_INUM (k) >= low && \
  310.                          SCM_INUM (k) < high)); \
  311.      } while (0)
  312.  
  313. #define SCM_VALIDATE_INUM_RANGE_COPY(pos, k, low, high, cvar) \
  314.   do { \
  315.     SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
  316.     SCM_ASSERT_RANGE (pos, k, low <= SCM_INUM (k) && SCM_INUM (k) < high); \
  317.     cvar = SCM_INUM (k); \
  318.   } while (0)
  319.  
  320. #define SCM_VALIDATE_NULL(pos, scm) SCM_MAKE_VALIDATE (pos, scm, NULLP)
  321.  
  322. #define SCM_VALIDATE_CONS(pos, scm) SCM_MAKE_VALIDATE (pos, scm, CONSP)
  323.  
  324. #define SCM_VALIDATE_LIST(pos, lst) \
  325.   do { \
  326.     SCM_ASSERT (scm_ilength (lst) >= 0, lst, pos, FUNC_NAME); \
  327.   } while (0)
  328.  
  329. #define SCM_VALIDATE_NONEMPTYLIST(pos, lst) \
  330.   do { \
  331.     SCM_ASSERT (scm_ilength (lst) > 0, lst, pos, FUNC_NAME); \
  332.   } while (0)
  333.  
  334. #define SCM_VALIDATE_LIST_COPYLEN(pos, lst, cvar) \
  335.   do { \
  336.     cvar = scm_ilength (lst); \
  337.     SCM_ASSERT (cvar >= 0, lst, pos, FUNC_NAME); \
  338.   } while (0)
  339.  
  340. #define SCM_VALIDATE_NONEMPTYLIST_COPYLEN(pos, lst, cvar) \
  341.   do { \
  342.     cvar = scm_ilength (lst); \
  343.     SCM_ASSERT (cvar >= 1, lst, pos, FUNC_NAME); \
  344.   } while (0)
  345.  
  346. #define SCM_VALIDATE_ALISTCELL(pos, alist) \
  347.   do { \
  348.     SCM_ASSERT (SCM_CONSP (alist) && SCM_CONSP (SCM_CAR (alist)), \
  349.                 alist, pos, FUNC_NAME); \
  350.   } while (0)
  351.  
  352. #define SCM_VALIDATE_ALISTCELL_COPYSCM(pos, alist, cvar) \
  353.   do { \
  354.     SCM_ASSERT (SCM_CONSP (alist), alist, pos, FUNC_NAME); \
  355.     cvar = SCM_CAR (alist); \
  356.     SCM_ASSERT (SCM_CONSP (cvar), alist, pos, FUNC_NAME); \
  357.   } while (0)
  358.  
  359. #define SCM_VALIDATE_OPORT_VALUE(pos, port) \
  360.   do { \
  361.     SCM_ASSERT (scm_valid_oport_value_p (port), port, pos, FUNC_NAME); \
  362.   } while (0)
  363.  
  364. #define SCM_VALIDATE_PRINTSTATE(pos, a) SCM_MAKE_VALIDATE(pos,a,PRINT_STATE_P)
  365.  
  366. #define SCM_VALIDATE_SMOB(pos, obj, type) \
  367.   do { \
  368.     SCM_ASSERT (SCM_TYP16_PREDICATE (scm_tc16_ ## type, obj), \
  369.                 obj, pos, FUNC_NAME); \
  370.   } while (0)
  371.  
  372. #define SCM_VALIDATE_THREAD(pos, a) SCM_MAKE_VALIDATE (pos, a, THREADP)
  373.  
  374. #define SCM_VALIDATE_THUNK(pos, thunk) \
  375.   do { \
  376.     SCM_ASSERT (SCM_NFALSEP (scm_thunk_p (thunk)), thunk, pos, FUNC_NAME); \
  377.   } while (0)
  378.  
  379. #define SCM_VALIDATE_SYMBOL(pos, sym) SCM_MAKE_VALIDATE (pos, sym, SYMBOLP)
  380.  
  381. #define SCM_VALIDATE_VARIABLE(pos, var) SCM_MAKE_VALIDATE (pos, var, VARIABLEP)
  382.  
  383. #define SCM_VALIDATE_MEMOIZED(pos, obj) SCM_MAKE_VALIDATE (pos, obj, MEMOIZEDP)
  384.  
  385. #define SCM_VALIDATE_CLOSURE(pos, obj) SCM_MAKE_VALIDATE (pos, obj, CLOSUREP)
  386.  
  387. #define SCM_VALIDATE_PROC(pos, proc) \
  388.   do { \
  389.     SCM_ASSERT (SCM_EQ_P (scm_procedure_p (proc), SCM_BOOL_T), proc, pos, FUNC_NAME); \
  390.   } while (0)
  391.  
  392. #define SCM_VALIDATE_NULLORCONS(pos, env) \
  393.   do { \
  394.     SCM_ASSERT (SCM_NULLP (env) || SCM_CONSP (env), env, pos, FUNC_NAME); \
  395.   } while (0)
  396.  
  397. #define SCM_VALIDATE_HOOK(pos, a) SCM_MAKE_VALIDATE (pos, a, HOOKP)
  398.  
  399. #define SCM_VALIDATE_RGXP(pos, a) SCM_MAKE_VALIDATE (pos, a, RGXP)
  400.  
  401. #define SCM_VALIDATE_DIR(pos, port) SCM_MAKE_VALIDATE (pos, port, DIRP)
  402.  
  403. #define SCM_VALIDATE_PORT(pos, port) SCM_MAKE_VALIDATE (pos, port, PORTP)
  404.  
  405. #define SCM_VALIDATE_INPUT_PORT(pos, port) \
  406.   SCM_MAKE_VALIDATE (pos, port, INPUT_PORT_P)
  407.  
  408. #define SCM_VALIDATE_OUTPUT_PORT(pos, port) \
  409.   SCM_MAKE_VALIDATE (pos, port, OUTPUT_PORT_P)
  410.  
  411. #define SCM_VALIDATE_FPORT(pos, port) SCM_MAKE_VALIDATE (pos, port, FPORTP)
  412.  
  413. #define SCM_VALIDATE_OPFPORT(pos, port) SCM_MAKE_VALIDATE (pos, port, OPFPORTP)
  414.  
  415. #define SCM_VALIDATE_OPINPORT(pos, port) \
  416.   SCM_MAKE_VALIDATE (pos, port, OPINPORTP)
  417.  
  418. #define SCM_VALIDATE_OPENPORT(pos,port) \
  419.   do { \
  420.     SCM_ASSERT (SCM_PORTP (port) && SCM_OPENP (port), \
  421.                 port, pos, FUNC_NAME); \
  422.   } while (0)
  423.  
  424. #define SCM_VALIDATE_OPPORT(pos, port) SCM_MAKE_VALIDATE (pos, port, OPPORTP)
  425.  
  426. #define SCM_VALIDATE_OPOUTPORT(pos, port) \
  427.   SCM_MAKE_VALIDATE (pos, port, OPOUTPORTP)
  428.  
  429. #define SCM_VALIDATE_OPOUTSTRPORT(pos, port) \
  430.   SCM_MAKE_VALIDATE (pos, port, OPOUTSTRPORTP)
  431.  
  432. #define SCM_VALIDATE_FLUID(pos, fluid) SCM_MAKE_VALIDATE (pos, fluid, FLUIDP)
  433.  
  434. #define SCM_VALIDATE_KEYWORD(pos, v) SCM_MAKE_VALIDATE (pos, v, KEYWORDP)
  435.  
  436. #define SCM_VALIDATE_STACK(pos, v) SCM_MAKE_VALIDATE (pos, v, STACKP)
  437.  
  438. #define SCM_VALIDATE_FRAME(pos, v) SCM_MAKE_VALIDATE (pos, v, FRAMEP)
  439.  
  440. #define SCM_VALIDATE_RSTATE(pos, v) SCM_MAKE_VALIDATE (pos, v, RSTATEP)
  441.  
  442. #define SCM_VALIDATE_ARRAY(pos,v) \
  443.   do { \
  444.     SCM_ASSERT (SCM_NIMP (v) \
  445.                 && !SCM_FALSEP (scm_array_p (v, SCM_UNDEFINED)), \
  446.                 v, pos, FUNC_NAME); \
  447.   } while (0)
  448.  
  449. #define SCM_VALIDATE_VECTOR(pos, v) SCM_MAKE_VALIDATE (pos, v, VECTORP)
  450.  
  451. #define SCM_VALIDATE_VECTOR_OR_DVECTOR(pos, v) \
  452.   do { \
  453.     SCM_ASSERT ((SCM_VECTORP (v) \
  454.                 || (SCM_NIMP (v) && SCM_TYP7 (v) == scm_tc7_dvect)), \
  455.                 v, pos, FUNC_NAME); \
  456.   } while (0)
  457.  
  458. #define SCM_VALIDATE_STRUCT(pos, v) SCM_MAKE_VALIDATE (pos, v, STRUCTP)
  459.  
  460. #define SCM_VALIDATE_VTABLE(pos, v) \
  461.   do { \
  462.     SCM_ASSERT (SCM_NIMP (v) && SCM_NFALSEP (scm_struct_vtable_p (v)), \
  463.                 v, pos, FUNC_NAME); \
  464.   } while (0)
  465.  
  466. #define SCM_VALIDATE_VECTOR_LEN(pos, v, len) \
  467.   do { \
  468.     SCM_ASSERT (SCM_VECTORP (v) && len == SCM_VECTOR_LENGTH (v), v, pos, FUNC_NAME); \
  469.   } while (0)
  470.  
  471.  
  472.  
  473. #if (SCM_DEBUG_DEPRECATED == 0)
  474.  
  475. #define SCM_FUNC_NAME (scm_makfrom0str (FUNC_NAME))
  476.  
  477. #define SCM_WTA(pos, scm) \
  478.   do { scm_wta (scm, (char *) pos, FUNC_NAME); } while (0)
  479.  
  480. #define RETURN_SCM_WTA(pos, scm) \
  481.   do { return scm_wta (scm, (char *) pos, FUNC_NAME); } while (0)
  482.  
  483. #define SCM_VALIDATE_NUMBER_COPY(pos, z, cvar)    \
  484.   do {                        \
  485.     if (SCM_INUMP (z))                \
  486.       cvar = (double) SCM_INUM (z);        \
  487.     else if (SCM_REALP (z))            \
  488.       cvar = SCM_REAL_VALUE (z);        \
  489.     else if (SCM_BIGP (z))            \
  490.       cvar = scm_i_big2dbl (z);            \
  491.     else                    \
  492.       {                        \
  493.     cvar = 0.0;                \
  494.         SCM_WRONG_TYPE_ARG (pos, z);        \
  495.       }                        \
  496.   } while (0)
  497.  
  498. #define SCM_VALIDATE_NUMBER_DEF_COPY(pos, number, def, cvar)    \
  499.   do {                                \
  500.     if (SCM_UNBNDP (number))                    \
  501.       cvar = def;                        \
  502.     else                            \
  503.       SCM_VALIDATE_NUMBER_COPY(pos, number, cvar);        \
  504.   } while (0)
  505.  
  506. #define SCM_VALIDATE_STRINGORSUBSTR SCM_VALIDATE_STRING
  507.  
  508. #define SCM_VALIDATE_ROSTRING(pos, str) SCM_MAKE_VALIDATE (pos, str, ROSTRINGP)
  509.  
  510. #define SCM_VALIDATE_ROSTRING_COPY(pos, str, cvar) \
  511.   do { \
  512.     SCM_ASSERT (SCM_ROSTRINGP (str), str, pos, FUNC_NAME); \
  513.     cvar = SCM_ROCHARS (str); \
  514.   } while (0)
  515.  
  516. #define SCM_VALIDATE_NULLORROSTRING_COPY(pos, str, cvar) \
  517.   do { \
  518.     SCM_ASSERT (SCM_FALSEP (str) || SCM_ROSTRINGP (str), \
  519.                 str, pos, FUNC_NAME); \
  520.     if (SCM_FALSEP(str)) \
  521.       cvar = NULL; \
  522.     else \
  523.       cvar = SCM_ROCHARS(str); \
  524.   } while (0)
  525.  
  526. #define SCM_VALIDATE_RWSTRING(pos, str) \
  527.   do { \
  528.     SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \
  529.     if (!SCM_RWSTRINGP (str)) \
  530.       scm_misc_error (FUNC_NAME, "argument is a read-only string", str); \
  531.   } while (0)
  532.  
  533. #define SCM_VALIDATE_OPDIR(pos, port) SCM_MAKE_VALIDATE (pos, port, OPDIRP)
  534.  
  535. #endif  /* SCM_DEBUG_DEPRECATED == 0 */
  536.  
  537. #endif
  538.  
  539. /*
  540.   Local Variables:
  541.   c-file-style: "gnu"
  542.   End:
  543. */
  544.